package com.ruoyi.service.project.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ruoyi.service.project.entity.ProjectEntity;
import com.ruoyi.service.project.query.ProjectQueryForLabor;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * <p>
 * 项目信息表 Mapper 接口
 * </p>
 *
 * @author Zane
 * @since 2025-10-08
 */
public interface ProjectMapper extends BaseMapper<ProjectEntity> {

  @Select("<script>"
      + "SELECT \n"
      + "  t.*, \n"
      + "  jt.* \n"
      + "FROM t_project t\n"
      + "JOIN JSON_TABLE(\n"
      + "  t.posts_info,\n"
      + "  '$[*]' COLUMNS (\n"
      + "    level VARCHAR(20) PATH '$.level',\n"
      + "    number INT PATH '$.number',\n"
      + "    isHiring INT PATH '$.isHiring',\n"
      + "    postCode VARCHAR(10) PATH '$.postCode',\n"
      + "    postName VARCHAR(50) PATH '$.postName',\n"
      + "    levelCode VARCHAR(10) PATH '$.levelCode',\n"
      + "    personDay INT PATH '$.personDay',\n"
      + "    salaryByDay INT PATH '$.salaryByDay'\n"
      + "  )\n"
      + ") AS jt "
      // 项目状态为已发布并且交付前
      + "where 1=1 and t.status &gt; 0 and t.status &lt; 4 "
      + "<if test=\"query.post != null and query.post != ''\">"
      + "and jt.isHiring = 1 AND jt.postCode = #{query.post}"
      + "</if>"
      + "</script>"
  )
  List<ProjectEntity> listForLabor(@Param("query") ProjectQueryForLabor query);
}
